<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
 * Created by JetBrains PhpStorm.
 * User: xx
 * Date: 14-1-23
 * Time: 下午3:06
 * To change this template use File | Settings | File Templates.
 */

/**
 * Class authentication
 * 权限基类
 */
class authentication
{
    var $whitelist;
    var $blacklist;

    public function __construct()
    {
        $this->whitelist = array(
            'welcome->index' => true,
            'login->do_login' => true,
            'loadjs->index' => true,
            'loadstyles->index' => true,
        );
        $this->blacklist = array();
    }

    /**
     * 鉴权
     * @param $c
     * @param $m
     * @return bool
     */
    public function permission($c, $m)
    {
        $key = $c . '->' . $m;

        if (isset($this->blacklist[$key])) {
            return false;
        }
        if (isset($this->whitelist[$key])) {
            return true;
        }
        return false;
    }
}